package com.elinshaw.pattern.single;

/**
 * 旅客线程
 */
public class Passengers extends Thread {

    private final FlightSecurity flightSecurity;

    /**
     * 登记牌
     */
    private final String boardingPass;

    /**
     * 身份证
     */
    private final String idCard;

    public Passengers(FlightSecurity flightSecurity, String boardingPass, String idCard) {
        this.flightSecurity = flightSecurity;
        this.boardingPass = boardingPass;
        this.idCard = idCard;
    }

    @Override
    public void run() {
        while (true) {
            flightSecurity.pass(boardingPass, idCard);
        }
    }

    public static void main(String[] args) {
        final FlightSecurity flightSecurity = new FlightSecurity();
        new Passengers(flightSecurity, "A123456", "AF123456").start();
        new Passengers(flightSecurity, "B123456", "BF123456").start();
        new Passengers(flightSecurity, "C123456", "CF123456").start();
    }


}
